package com.focusai.efairy.utils;

import com.focusai.efairy.R;

/**
 * Created by luo_guangwen on 2017/8/13.
 */

public class StrByCodeUtils {
    /**
     *  efairydevice_alarm_id:int, // 报警值，0-离线 1-火警 2-预警 3-故障 4-启动 5-屏蔽 6-正常
     * */
    public static String getStatusByAlarmId(int alarmId){
        String msg = "离线";
        switch (alarmId){
            case 0:
                break;
            case 1:
                msg = "火警";
                break;
            case 2:
                msg = "预警";
                break;
            case 3:
                msg = "故障";
                break;
            case 4:
                msg = "启动";
                break;
            case 5:
                msg = "屏蔽";
                break;
            case 6:
                msg = "正常";
                break;
            default:
                break;
        }
        return msg;
    }


    /**
     * 设备状态，0-离线 1-火警 2-预警 3-故障 4-启动 5-屏蔽 6-正常  //正常：5-屏蔽、6-正常；
     *故障：0-离线、3-故障；
     *报警：1-火警、2-预警、4-启动；
     * */
    public static String getStatusByDevState(int stateId){
        String msg = "";
        switch (stateId){
            case 1:
            case 2:
            case 4:
                msg = "报警";
                break;
            case 0:
            case 3:
                msg = "故障";
                break;
            case 5:
            case 6:
                msg = "正常";
                break;
            default:
                break;
        }
        return msg;
    }

    public static String getStatusByDevOnline(int is_online){
       if (is_online == 0){
           return "离线";
       }
       return "在线";
    }

    public static int getColorByDevState(int stateId){
        int color = R.color.dev_status_green;
        switch (stateId){
            case 1:
            case 2:
            case 4:
                color = R.color.dev_status_red;
                break;
            case 0:
            case 3:
                color = R.color.dev_status_yellow;
                break;
            case 5:
            case 6:
                color = R.color.dev_status_green;
                break;
            default:
                break;
        }
        return color;
    }

    public static String getStrMaintainByType(int typeId){
        String str = "常规巡检";
        switch (typeId){
            case 1:
                str = "产品故障";
                break;
            case 2:
                str = "通讯故障";
                break;
            case 3:
                str = "其它";
                break;

            default:
                break;
        }
        return str;
    }
    public static String getStrMaintainByHandId(int typeId,int handId){
        String str = "故障已排除";
        if (typeId == 4){
            if (handId == 1){
                str = "异常";
            }else {
                str = "正常";
            }
        }
        if (handId == 0){
            str = "故障待排除";
        }
        return str;
    }
}
